#include<reg51.h>

#define NODE2_ADDR 2

unsigned char pointer = 0;

sbit key = P1^0;

unsigned char str[] = {"0123456789ABCDEFG"};

unsigned char num[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xd8,0x80,0x90};


void delay(unsigned int time)
{
    unsigned char i, j;
    for (i = 0; i < 123; i++)
    {
        for (j = 0; j < time; j++);
    }
}

void main()
{
    SCON = 0xe0;
    TMOD = 0x20; 
    TH1 = TL1 = 0xfd;
    TR1 = 1;
    while (1)
    {
        if (P1 == 0xfe)
        {
            delay(250);	
            TB8 = 1; 
            SBUF = NODE2_ADDR;
            while(!TI);
            TI = 0; 
            TB8 = 0;
            SBUF = str[pointer++];
            if(pointer <= 10)
            {
                P0 = num[pointer];
            }else{
                pointer = 0;
                break;
            }
            while (!TI);
            TI = 0;
        }
    }
}

